package ningbo.set;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @Author 宁铂
 * @Date 2021/7/28 14:51
 * @Version 1.0
 */
public class TestMap2 {
    /** 本类用于字符串中字符个数统计案例 */
    public static void main(String[] args) {
        System.out.println("输入要统计的字符串");
        String input = new Scanner(System.in).nextLine();

        Map<Character,Integer> map = new HashMap<>();

        for (int i = 0 ; i <= input.length()-1; i++){

            char key = input.charAt(i);
            Integer integer = map.get(key);

            if (integer == null){
                map.put(key, 1);
            }else{
                map.put(key, integer+1);
            }

        }
        System.out.println(map);
    }
}
